<?
session_start();
include('conn.php');
$qry1 = "SELECT * from canceltrandetails where status=0 order by cantrndetid desc ";

//LEFT JOIN customermast V ON A.agentid = V.custid where  V.custtype = 'Vendor'  and 

$qry = mysql_query($qry1);
$data = array();
$i=1;
while($rows = mysql_fetch_array($qry))
{
	if (strcmp ($rows['Refund_Date'],'0000-00-00')==0)
		$r1='-';
	else
		$r1=$rows['Refund_Date'];
	if (strcmp ($rows['Reference_Date'],'0000-00-00')==0)
		$r2='-';
	else
		$r2=$rows['Reference_Date'];
		
	$q = "select custdesc from customermast where custid = '".$rows['agentid']."';";
	$re=mysql_query($q);
	while($row = mysql_fetch_array($re))
		$aname = $row['custdesc'];
	//echo $aname;
	
	$data[] = array("cantrndetid" => $rows['cantrndetid'],
					"PNRNumber"   =>$rows['PNRNumber'],
        			"Can_Date" => $rows['Can_Date'],
					"agentid"   =>$rows['agentid'],
					"aname"   =>$aname,					
					"Pax_Name" => $rows['Pax_Name'],
				  "No_of_Pax" => $rows['No_of_Pax'],
				  "Airline" => $rows['Airline'],
				  "Sector"=> $rows['Sector'],
				  "Net_Rate"=> $rows['Net_Rate'],
				  "Refund_Amt"=> $rows['Refund_Amt'],
                    "Refund_Date"=> $r1,
                   "Agent_Rate"=> $rows['Agent_Rate'],
                   "Agent_Ref_Amt"=> $rows['Agent_Ref_Amt'],
                   "Reference_Date"=> $r2,
                   "Comment"=> $rows['Comment'],
                   "enteredby"=> $rows['enteredby'],
                   "entrydt"=> $rows['entrydt'],
                   "status"=> $rows['status']);
}
echo json_encode($data);
?>